<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:data="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<head th:include="include/include">
</head>
<style>
    .select-form-control + .form-control-feedback{
        top: 0;
        right: -25px;
        /*width: 20px;*/
        /*height: 20px;*/
        /*line-height: 20px;*/
    }
</style>
<script>
    window.feeUpdateEvent={
        "blur .editFee":function(e,value,row,index){
            var oldValue=this.defaultValue;
            var newValue=$(this).val();
            this.defaultValue=newValue;
            console.log(row+",value="+newValue+",oldValue="+oldValue+"index="+index);

        }
    }
    // //禁止滚动条
    // $(document.body).css({
    //     "overflow-x":"hidden",
    //     "overflow-y":"auto"
    // });
    $(function () {
        //添加配件
        $("#addParts").click(function(){
            addParts();
        });
        $('#fixedLossPricingDetailTable a').editable({
            type: 'text',
            name: 'xzmc_0',
            url: '/post',
            title: 'Enter username'
        });

        $('#carRegisterDate').datetimepicker({
            "format": 'yyyy-mm-dd'
            ,"language":"zh-CN",
            weekStart: 1, //一周从哪一天开始
            todayBtn:  "linked",
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView:'year',
            maxView:'decade'
            ,initialDate: new Date()
        });

        $('#produceDate').datetimepicker({
            "format": 'yyyy-mm-dd'
            ,"language":"zh-CN",
            weekStart: 1, //一周从哪一天开始
            todayBtn:  "linked",
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView:'year',
            maxView:'decade'
            ,initialDate: new Date()
        });
        $('#outDangerDate').datetimepicker({
            "format": 'yyyy-mm-dd hh:ii:ss'
            ,"language":"zh-CN",
            weekStart: 1, //一周从哪一天开始
            todayBtn:  "linked",
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1
            // ,"startDate":"2018-01-01"
            ,initialDate: new Date()
        });
        formValidator();
        //禁用表格编辑 参考
        $('#manHour').on( 'click', 'td:has(.editable)', function (e) {
            //e.preventDefault();
            e.stopPropagation(); // 阻止事件的冒泡行为
           // $(this).find('.editable').editable('show'); // 打开被点击单元格的编辑状态
            //$(this).find('.editable').attr("disabled","disabled");//设置失败
            //alert(JSON.stringify($("#manHour").bootstrapTable("getOptions")));
        } );

    });
    /*验证提交信息*/
    function formValidator() {
        $("#formdemo").bootstrapValidator({
            live:"enabled",/*验证时机，enabled是内容有变化就验证（默认），disabled和submitted是提交再验证*/
            message:"通用的验证失败信息",
            feedbackIcons:{//根据验证结果显示的各种图标
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                repairDepotName:{
                    message: ' ',
                    validators: {
                        notEmpty: {
                            message: ''
                        }
                    }
                }
                ,repairDepotType:{
                    message: ' ',
                    validators: {
                        notEmpty: {
                            message: ''
                        }
                    }
                }
                ,chooseRepairDepotType:{
                    message: ' ',
                    validators: {
                        notEmpty: {
                            message: ''
                        }
                    }

                }
                ,'car.licenceNo':{
                    message:' ',
                    validators:{
                        notEmpty:{
                            message:' '
                        }
                        ,regexp:{
                            regexp: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
                            message:' '
                        }
                    }

                }
                ,orgCode:{
                    message:'',
                    validators:{
                        notEmpty:{
                            message:' '
                        },
                        stringLength:{
                            min:4,
                            max:10,
                            message:' '
                        }

                    }

                }
                ,'recognizee':{
                    message:'',
                    validators:{
                        stringLength:{
                            min:2,
                            max:10,
                            message:' '
                        }

                    }
                }
                ,'car.driverName':{
                    message:'',
                    validators:{
                        stringLength:{
                            min:2,
                            max:10,
                            message:' '
                        }

                    }
                }
                ,'car.modelType':{
                    message:'',
                    validators:{
                        notEmpty:{
                            message:' '
                        }

                    }

                }
                ,'car.vinNo':{
                    message:'',
                    validators:{
                        stringLength:{
                            min:2,
                            max:30,
                            message:' '
                        }

                    }

                }
                ,'car.engineNo':{
                    message:'',
                    validators:{
                        stringLength:{
                            min:2,
                            max:30,
                            message:' '
                        }

                    }

                }
                ,'car.ableCarModel':{
                    message:'',
                    validators:{
                        notEmpty:{
                            message:' '
                        }

                    }

                }
                ,'car.manufactuer':{
                    message:'',
                    validators:{
                        notEmpty:{
                            message:' '
                        }

                    }

                }
                ,'fixedLossTotal':{
                    validators: {
                        notEmpty: {
                            message: ' '
                        }
                        ,numeric:{
                            message:' '
                        }
                        ,lessThan: {
                            message:' ',
                            value: 10000000000
                        }
                        ,greaterThan: {
                            message:' ',
                            value: 1
                        }

                    }

                }
                ,'car.newCarPrice':{ validators: {
                        notEmpty: {
                            message: ' '
                        }
                        ,numeric:{
                            message:' '
                        }
                        ,lessThan: {
                            message:' ',
                            value: 10000000000
                        }
                        ,greaterThan: {
                            message:' ',
                            value: 1
                        }

                    }


                }


            }

        })
        
    }
    /* 保存*/
    function save(){
        //保存勘查信息
        var myform=$("#formdemo");
        var url=myform.attr("action");
        // myform.data('bootstrapValidator').validate();
        $("#formdemo").data('bootstrapValidator').validate();
        //console.log($("#formdemo").data('bootstrapValidator')+"在这");
        if ($("#formdemo").data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码

            //清楚验证规则
            $("#formdemo").data('bootstrapValidator').destroy();
            $("#formdemo").data('bootstrapValidator',null);
            $.post(url,$("#formdemo").serialize(),function(data){
                alert(data.msg);
                if(data.result){
                    $("#saveBtn").attr("disabled",true);
                    $("#saveBtn").removeClass("btn-info");
                }
            });
        }else{
            alert("信息未填写完整");
        }
    }
    //修改配件
    function updatetr(val,id){
        BootstrapDialog.show({
            title: '修改信息 ' ,
            message: function(dialog) {
                var $message = $('<div></div>');
                var pageToLoad = dialog.getData('pageToLoad');
                $message.load(pageToLoad);

                return $message;
            },
            data: {
                'pageToLoad': 'fixedLoss_checkPrice_Add',
                'dataId':id
            },
            buttons:[{
                    label: '修改',
                    title: 'Mouse over Button 1',
                    action: function (dialog) {
                        //开始
                        var myform=$('#addpartsform');
                        //var url=myform.attr("action");
                        myform.data('bootstrapValidator').validate();
                        //console.log("huoquduixiang:"+insuranceTypeName+"参数"+$('#addpartsform').data("bootstrapValidator"))
                        //console.log($("#formdemo").serialize());
                        if (myform.data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码

                            //清楚验证规则
                            myform.data('bootstrapValidator').destroy();
                            myform.data('bootstrapValidator',null);
                            // $.post(url,$("#formdemo").serialize(),function(data){
                            //     alert(data.msg);
                            //     if(data.result){
                            //         $("#saveBtn").attr("disabled",true);
                            //         $("#saveBtn").removeClass("btn-info");
                            //     }
                            // });
                            $.ajax({
                                url:"fixedLossCheckPriceDetail/add",
                                data:params,
                                dataType:"JSON",
                                type:"POST",
                                async:false,
                                success:function(data) {
                                    if(data!=null){
                                        if(data.status==1){
                                            dialog.close();
                                            var item=data.data;
                                            var str="<tr>"+
                                                "<td><label>"+
                                                item.xzmc+

                                                "</label>"+
                                                "</td> " +
                                                "<td >" +
                                                "<label><input value='"+item.pjmc+"'class='width80'/> <span class='glyphicon glyphicon-pencil'></span></label> " +
                                                "</td>" +
                                                "<td>" +
                                                "<label >"+item.bdjg+"</label>" +
                                                "</td>"+
                                                "<td class='width80'>"+
                                                "<label >"+item.xtjg+"</label>"+
                                                "</td>" +
                                                "<td >" +
                                                "<label >"+item.sl+"</label>" +
                                                "</td>" +
                                                "<td>" +
                                                "<label >"+item.dsj+"</label>" +
                                                "</td>" +
                                                "<td>" +
                                                "<label >"+item.hj+"</label>"+
                                                "</td>" +
                                                "<td><label class='width80'>"+item.jgan+"</label></td>" +
                                                "<td class='width80'>"+
                                                "<label class='checkbox'>" ;
                                            if(item.sfhs==1){
                                                str+= "<input type='checkbox' name=''checked />" ;
                                            }else{
                                                str+= "<input type='checkbox' name='' />" ;
                                            }


                                            str+=  "</label>" +
                                                "</td>" +
                                                "<td ><label>";
                                            if(item.zhuangtai==1){
                                                str+="完成";
                                            }else{
                                                str+="未完成";
                                            }

                                            str+="</lable></td>" +
                                                "<td><span class='glyphicon glyphicon-remove-sign' style='color: rgb(255, 140, 60);' onclick='deletetr(this,"+item.ids+");'></span><span class='glyphicon glyphicon-floppy-disk' style='color: rgb(255, 140, 60);margin-left: 10px;'> </span><span class='glyphicon glyphicon-pencil' style='color: rgb(255, 140, 60);margin-left: 10px;' onclick='updatetr(this,"+item.ids+");'> </span></td>" +
                                                "</tr>";
                                            $("#tr_addParts").before(str);
                                        }else{
                                            BootstrapDialog.show({
                                                title: '提示信息',
                                                message: '添加失败!',
                                                size:BootstrapDialog.SIZE_SMALL,
                                                type: BootstrapDialog.TYPE_WARNING,
                                                buttons: [{
                                                    label: '关闭',
                                                    action: function(dialog){
                                                        // dialog.setTitle('Normal');
                                                        // dialog.setSize(BootstrapDialog.SIZE_NORMAL);
                                                        dialogItself.close();
                                                    }
                                                }]
                                            });

                                        }

                                    }
                                    //alert(data.msg);

                                }
                            })
                        }else{
                            alert("信息未填写完整");
                        }
                        //结束


                    }

                },  {
                    label: '关闭',
                    action: function(dialogItself) {
                        dialogItself.close();
                }
            }],
            onshown : function(dialogRef) {
                /*setTimeout(function() {
                    dialogRef.close();
                }, 1000);*/
                var label=$(val).parent().parent().find("label");
                var insuranceTypeName=label.eq(0).text();
                var partsName=label.find("input").val();
                var localPrice=label.eq(2).text();
                var systemPrice=label.eq(3).text();
                var count=label.eq(4).text();
                var fixedLossPrice=label.eq(5).text();
                var checkPricePrice=label.eq(6).text();
                var pricePaln=label.eq(7).text();
                var isRecycle=label.eq(8).text();
                var status=label.eq(9).text();

                var modalBody=dialogRef.getModalBody();
                modalBody.find('#ids').val(id);//id
               // modalBody.find('#insuranceTypeName').val(insuranceTypeName);
                if(insuranceTypeName=="险种2"){
                    $("#insuranceTypeName option:contains('"+insuranceTypeName+"') ").attr("selected",true);
                }
                modalBody.find('#count').val(count);
                modalBody.find('#partsName').val(partsName);
                modalBody.find('#localPrice').val(localPrice);
                modalBody.find('#systemPrice').val(systemPrice);
                modalBody.find('#pricePaln').val(pricePaln);
                modalBody.find('#checkPricePrice').val(checkPricePrice);
                modalBody.find('#fixedLossPrice').val(fixedLossPrice);
                if(status==0){
                    $("#status option[value='0'] ").attr("selected",true);
                }
                if(isRecycle==0){
                    $("#isRecycle option[value='0'] ").attr("selected",true);
                }
            }

        });

    }

    //添加配件方法
    function addParts(){

        BootstrapDialog.show({
            type: BootstrapDialog.TYPE_DANGER,
            title: '添加信息 ' ,
            message: $('<div></div>').load('fixedLoss_checkPrice_Add'),//加载 添加页面
            closeByBackdrop: false,
            closeByKeyboard: false,
            buttons: [{
                label: '保存',
                title: 'Mouse over Button 1',
                action:function(dialog){
                    //$("#addpartsform")
                   var insuranceTypeName= dialog.getModalBody().find('#addpartsform');//获取定价核损
                    var params=decodeURIComponent(insuranceTypeName.serialize(),true);//解决序列化乱码问题
                    params+="&taskNo="+taskNo;
                    //开始
                    var myform=$('#addpartsform');
                    //var url=myform.attr("action");
                    myform.data('bootstrapValidator').validate();
                    //console.log("huoquduixiang:"+insuranceTypeName+"参数"+$('#addpartsform').data("bootstrapValidator"))
                    //console.log($("#formdemo").serialize());
                    if (myform.data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码

                        //清楚验证规则
                        myform.data('bootstrapValidator').destroy();
                        myform.data('bootstrapValidator',null);
                        // $.post(url,$("#formdemo").serialize(),function(data){
                        //     alert(data.msg);
                        //     if(data.result){
                        //         $("#saveBtn").attr("disabled",true);
                        //         $("#saveBtn").removeClass("btn-info");
                        //     }
                        // });
                        $.ajax({
                            url:"fixedLossCheckPriceDetail/add",
                            data:params,
                            dataType:"JSON",
                            type:"POST",
                            async:false,
                            success:function(data) {
                                if(data!=null){
                                    if(data.status==1){
                                        dialog.close();
                                        var item=data.data;
                                        var str="<tr>"+
                                            "<td><label>"+
                                            item.xzmc+

                                            "</label>"+
                                            "</td> " +
                                            "<td >" +
                                            "<label><input value='"+item.pjmc+"'class='width80'/> <span class='glyphicon glyphicon-pencil'></span></label> " +
                                            "</td>" +
                                            "<td>" +
                                            "<label >"+item.bdjg+"</label>" +
                                            "</td>"+
                                            "<td class='width80'>"+
                                            "<label >"+item.xtjg+"</label>"+
                                            "</td>" +
                                            "<td >" +
                                            "<label >"+item.sl+"</label>" +
                                            "</td>" +
                                            "<td>" +
                                            "<label >"+item.dsj+"</label>" +
                                            "</td>" +
                                            "<td>" +
                                            "<label >"+item.hj+"</label>"+
                                            "</td>" +
                                            "<td><label class='width80'>"+item.jgan+"</label></td>" +
                                            "<td class='width80'>"+
                                            "<label class='checkbox'>" ;
                                        if(item.sfhs==1){
                                            str+= "<input type='checkbox' name=''checked />" ;
                                        }else{
                                            str+= "<input type='checkbox' name='' />" ;
                                        }


                                        str+=  "</label>" +
                                            "</td>" +
                                            "<td ><label>";
                                        if(item.zhuangtai==1){
                                            str+="完成";
                                        }else{
                                            str+="未完成";
                                        }

                                        str+="</lable></td>" +
                                            "<td><span class='glyphicon glyphicon-remove-sign' style='color: rgb(255, 140, 60);' onclick='deletetr(this,"+item.ids+");'></span><span class='glyphicon glyphicon-floppy-disk' style='color: rgb(255, 140, 60);margin-left: 10px;'> </span><span class='glyphicon glyphicon-pencil' style='color: rgb(255, 140, 60);margin-left: 10px;' onclick='updatetr(this,"+item.ids+");'> </span></td>" +
                                            "</tr>";
                                        $("#tr_addParts").before(str);
                                    }else{
                                        BootstrapDialog.show({
                                            title: '提示信息',
                                            message: '添加失败!',
                                            size:BootstrapDialog.SIZE_SMALL,
                                            type: BootstrapDialog.TYPE_WARNING,
                                            buttons: [{
                                                label: '关闭',
                                                action: function(dialog){
                                                    // dialog.setTitle('Normal');
                                                    // dialog.setSize(BootstrapDialog.SIZE_NORMAL);
                                                    dialogItself.close();
                                                }
                                            }]
                                        });

                                    }

                                }
                                //alert(data.msg);

                            }
                        })
                    }else{
                        alert("信息未填写完整");
                    }
                    //结束






                }
            },  {
                label: '关闭',
                action: function(dialogItself){
                    dialogItself.close();
                }
            }]
        });

    }

//    添加费用
    function addCost(){
        var str="<tr>  " +
            "                                        <td>  " +
            "                                            <label>  " +
            "                                                <select>  " +
            "                                                    <option value=''>车辆损失险</option>  " +
            "                                                </select>  " +
            "                                            </label>  " +
            "                                        </td>  " +
            "                                        <td>  " +
            "                                            <label>  " +
            "                                                <select>  " +
            "                                                    <option value=''>施救费</option>  " +
            "                                                </select>  " +
            "                                            </label>  " +
            "                                        </td>  " +
            "                                        <td>  " +
            "                                            <label><input value=''/></label>  " +
            "                                        </td>  " +
            "                                        <td>  " +
            "                                            <label><input value=''/></label>  " +
            "                                        </td>  " +
            "                                        <td> " +
            "                                            <label><input value=''/></label>" +
            "                                       </td> " +
            "                                       <td> " +
            "                                           <span class='glyphicon glyphicon-remove-sign ' onclick='deletetr(this);'></span>" +
            "                                       </td>" +
            "   </tr>";
        $("#tr_addCost").before(str);
    }
    //删除当前行
    function deletetr(tr,val){
        if(val!=''&&typeof  val!='undefined'){
            $.ajax({
                url:"fixedLossCheckPriceDetail/deleteById",
                data:{id:val},
                dataType:"JSON",
                type:"GET",
                async:false,
                success:function(data){
                    if(data!=null){
                        if(data.status==1){
                            $(tr).parent().parent().remove();
                        }

                    }


                },
                error:function(){

                }
            })


        }


    }
    //添加项目
    function addItems(val) {
        var str="<tr>\n" +
            "                                            <td><label>\n" +
            "                                                <select>\n" +
            "                                                    <option value=\"0\">--请选择--</option>\n" +
            "                                                    <option value=\"1\">车辆损失险</option>\n" +
            "                                                </select>\n" +
            "                                            </label></td>\n" +
            "                                            <td>\n" +
            "                                                <label><input value=\" \" name=\"\"/></label>\n" +
            "                                            </td>\n" +
            "                                            <td>\n" +
            "                                                <label><input value=\" \" name=\"\"/></label>\n" +
            "                                            </td>\n" +
            "                                            <td>\n" +
            "                                                <label><input value=\" \" name=\"\"/></label>\n" +
            "                                            </td>\n" +
            "                                            <td>\n" +
            "                                                <span class=\"glyphicon glyphicon-star\"></span>\n" +
            "                                            </td>\n" +
            "                                            <td style=\"text-align: center\">\n" +
            "                                                <span class=\"glyphicon glyphicon-remove-sign \" onclick=\"deletetr(this);\"></span>\n" +
            "                                                <!--onclick='localCarEdit(this,4)'-->\n" +
            "                                                <span class='glyphicon glyphicon-pencil margin5Left' ></span>\n" +
            "                                            </td>\n" +
            "                                        </tr>";
        $(val).parent().parent().before(str);
        
    }
    var taskNo='';
    //供父页面调用
    function getParentData2(val,data){//任务号val,和数组数据data
        taskNo=val;
        $.get("claimTask/getById",{id:data[0]},function(data){//获取本车定损页面的基本信息

            if(data!=null){
                var datas=data.data;
                if(datas!=null){
                    var licenceNo=$("#licenceNo").val(datas.chepaihao);//车牌
                    $("#repairDepotName").val(datas.xlcmc);//修理厂名称
                    var repairDepotType =datas.xlclx;//修理厂类型
                    $("#repairDepotType option[value='"+repairDepotType+"']").attr("selected",true);
                    $("#chooseRepairDepotType").val(datas.xlcqk);//修理厂情况
                    $("#recognizee").val(datas.insuredName);//被保险人
                    $("#driverName").val(datas.licenseOwner);//行驶车主
                    var licenseNoType=datas.hplx;//号牌种类
                    $("#licenseNoType option:contains('"+licenseNoType+"')").attr("selected",true);
                    $("#vinNo").val(datas.carVin);//车架号
                    $("#engineNo").val(datas.engineNo);//发动机号
                    $("#driver").val(datas.jsyxm);//驾驶员姓名
                    $("#idCard").val(datas.credentislasNum);//证件号码
                    $("#manufactuer").val(datas.sccs);//生产厂商
                    $("#brand").val(datas.pp);//车辆品牌
                    $("#series").val(datas.cxxl);//车型系列
                    $("#model").val(datas.clxh);//车辆型号
                    $("#produceDate").val(datas.scnf);//上产年份
                    $("#fixedLossTotal").val(datas.csdshj);//车损定损合计
                    var fixedLossInsureType=datas.dsxz;//定损险种
                    $("#fixedLossInsureType option:contains('"+fixedLossInsureType +"')").attr("selected",true);
                    var accidentDuty= datas.sgzr//事故责任
                    $("#accidentDuty option:contains('"+accidentDuty+"')").attr("selected",true);
                    $("#accidentDutypPercent").val(datas.sgzrbfb);//事故责任百分比
                    $("#checkPriceTotal").val(datas.cshshj);//车损核价合计
                    console.log(datas);
                }else{

                }

            }

        });
        //获取定损核价明细列表
        if(val!=''&&typeof val!='undefined'){
            tableInit(val);
            var assessmentLossCheckPriceTableInit = new AssessmentLossCheckPriceTableInit(val);
            assessmentLossCheckPriceTableInit.Init();
            var manHourInit=new ManHourInit(val);
            manHourInit.Init();
            //以下废弃
            $.post("fixedLossCheckPriceDetail/query",{renwubianhao:val},function(data){
                console.log(data.data);
                if(data!=null){
                    if(data.data!=null){
                        /*var json=JSON.stringify(data.data);
                        console.log(json);*/
                        $.each(data.data,function(index,item){

                                var str="<tr>"+
                                    "<td><label><a href='#' data-pk='"+index+"' id='xzmc_"+index+"'>"+
                                    item.xzmc+

                                    "</a></label>"+
                                    "</td> " +
                                    "<td >" +
                                    "<label><input value='"+item.pjmc+"'class='width80'/> <span class='glyphicon glyphicon-pencil'></span></label> " +
                                    "</td>" +
                                    "<td>" +
                                    "<label >"+item.bdjg+"</label>" +
                                    "</td>"+
                                    "<td class='width80'>"+
                                    "<label >"+item.xtjg+"</label>"+
                                    "</td>" +
                                    "<td >" +
                                    "<label >"+item.sl+"</label>" +
                                    "</td>" +
                                    "<td>" +
                                    "<label >"+item.dsj+"</label>" +
                                    "</td>" +
                                    "<td>" +
                                    "<label >"+item.hj+"</label>"+
                                    "</td>" +
                                    "<td><label class='width80'>"+item.jgan+"</label></td>" +
                                    "<td class='width80'>"+
                                        "<label class='checkbox'>" ;
                                if(item.sfhs==1){
                                    str+= "<input type='checkbox' name=''checked />" ;
                                }else{
                                    str+= "<input type='checkbox' name='' />" ;
                                }


                                      str+=  "</label>" +
                                    "</td>" +
                                    "<td ><label>";
                                        if(item.zhuangtai==1){
                                            str+="完成";
                                        }else{
                                            str+="未完成";
                                        }

                                    str+="</lable></td>" +
                                    "<td><span class='glyphicon glyphicon-remove-sign' style='color: rgb(255, 140, 60);' onclick='deletetr(this,"+item.ids+");'></span><span class='glyphicon glyphicon-floppy-disk' style='color: rgb(255, 140, 60);margin-left: 10px;'> </span><span class='glyphicon glyphicon-pencil' style='color: rgb(255, 140, 60);margin-left: 10px;' onclick='updatetr(this,"+item.ids+");'> </span></td>" +
                                    "</tr>";
                                $("#tr_addParts").before(str);
                        })
                    }


                }

            })
        }else{
            alert("未获取到本车定损的任务编号");
        }





    }
    //估损核价表格
    var AssessmentLossCheckPriceTableInit=function(renwuhao){
        var oAssessmentLossCheckPriceTableInit=new Object();
        oAssessmentLossCheckPriceTableInit.Init=function () {
            var $table=$('#assessmentLossCheckPriceTable');
            $('#assessmentLossCheckPriceTable').bootstrapTable({
                url: 'assessmentLossCheckPriceDetail/list',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                contentType : "application/x-www-form-urlencoded",//添加此方法使后台可以获取数据
                //toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sortable: false,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oAssessmentLossCheckPriceTableInit.queryParams,//传递参数（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber:1,                       //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [10, 20, 30, 50],        //可供选择的每页的行数（*）
                // search: true,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                // strictSearch: true,
                showColumns: true,                  //是否显示所有的列
                showRefresh: true,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                //clickToSelect: true,                //是否启用点击选中行
                //height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                //uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
                showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                showFooter:true,//显示页脚
                columns: [{
                    checkbox: true
                }, {
                    field: 'xzmc',
                    title: '险种名称'
                }, {
                    field: 'xlxm',
                    title: '修理项目'
                }, {
                    field: 'gsbj',
                    title: '工时费报价',
                    editable:{
                        type:'text',
                        title:'工时费报价',
                        validate:function(v){
                            if (!v) return '不能为空';
                            var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                            if (!reg.test(v)){
                                return "金额的输入格式不正确,请确认!";
                            }
                        }

                    },
                    footerFormatter: function (value) {
                        var count=0;
                        for (var i in value) {
                            var val=value[i].gsbj;
                            if(!isNaN(value[i].gsbj)){
                                //console.log("数据类型:"+ typeof parseFloat(value[i].gsbj))
                                count += (parseFloat(value[i].gsbj));
                            }

                        }
                        return "总计："+count.toFixed(2);
                    }


                }, {
                    field: 'gsfhs',
                    title: '工时费核损',
                    editable:{
                        type:'text',
                        title:'工时费核损',
                        validate:function(v){
                            if (!v) return '不能为空';
                            var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                            if (!reg.test(v)){
                                return "金额的输入格式不正确,请确认!";
                            }
                        }
                    },
                    footerFormatter: function (value) {
                        var sum=0;

                        for (var k in value) {
                            var val=value[k].gsfhs;


                            if(val!="工时费核损"){
                                if(!isNaN(val)){
                                    //console.log("输出值："+val);

                                    sum = (parseFloat(sum)+parseFloat(val));

                                }
                            }


                        }
                        return "总计:"+sum.toFixed(2);
                        /* var sum=0;
                         for (var i=0;i<value.length;i++) {
                             sum += value[i].gsfhs
                         }
                         return sum+"元";
 */
                    }
                },{
                    field: 'zhuangtai',
                    title: '状态',
                    editable: {
                        type: 'select',//下拉框
                        title: '状态',
                        source: [{value: "1", text: "已完成"}, {value: "0", text: "未完成"}]
                    }
                },
                    {
                        field: 'ids',
                        title: '操作',
                        width: 120,
                        align: 'center',
                        valign: 'middle',
                        formatter: function actionFormatter(value, row, index) {
                            ///* onclick='delFixedLossCheckPriceDetail("+row.ids+");'*/
                            return "<button type='button'class='delAssessmentLossCheckPriceDetail'>删除</button>";
                        },events: {
                            'click .delAssessmentLossCheckPriceDetail': function(e, value, row, index) {

                                //alert("e="+e+",value="+value+",index"+index);
                                BootstrapDialog.show({
                                    title: '确认删除',
                                    message: '是否删除？',
                                    type:BootstrapDialog.TYPE_WARNING,
                                    size:BootstrapDialog.SIZE_SMALL,
                                    buttons: [{
                                        label: '确认',
                                        action: function(dialog) {
                                            console.log("id==="+JSON.stringify(row));

                                            $.ajax({
                                                url:"assessmentLossCheckPriceDetail/delById",
                                                data:{id:row.ids},
                                                dataType:"JSON",
                                                type:"GET",
                                                async:false,
                                                success:function(data){
                                                    if(data!=null){
                                                        if(data.status==1){
                                                            $('#assessmentLossCheckPriceTable').bootstrapTable('remove',{
                                                                field:'ids',
                                                                values:[row.ids],
                                                            })
                                                            dialog.close();
                                                        }

                                                    }


                                                },
                                                error:function(){

                                                }
                                            })


                                        }
                                    }, {
                                        label: '取消',
                                        action: function(dialog) {
                                            dialog.close();
                                        }
                                    }]
                                });

                            }
                        }
                    },],
                onEditableSave: function (field, row, oldValue, $el) {
                    //$table = $('#table1').bootstrapTable({});
                    //console.log("field="+field+",oldValue="+oldValue+",newval="+row[field]);
                    var newValue=row[field];
                    if(''!=newValue) {
                        if (newValue != oldValue) {
                            var map=new Map();
                            map[field]=newValue;
                            map['ids']=row.ids;
                            $.ajax({
                                url: 'assessmentLossCheckPriceDetail/update',
                                data: map,
                                dataType: 'JSON',
                                type: 'POST',
                                async: false,
                                success: function (data) {
                                    console.log(data.status);
                                    if (data.status == 1) {
                                        //saveData(index, field, tdValue);
                                        //$table.bootstrapTable('updateRow', {index: row.rowId, row: row});
                                    } else {
                                        BootstrapDialog.show({
                                            title: '提示信息',
                                            message: data.msg,
                                            type: BootstrapDialog.TYPE_WARNING,
                                            size: BootstrapDialog.SIZE_SMALL,
                                            buttons: [{
                                                label: '确认',
                                                action: function (dialog) {
                                                    dialog.close();
                                                }
                                            }]
                                        });

                                    }

                                },
                                error: function () {

                                }


                            })
                        }
                    }

                },

                onPostBody: function (data) {
                    //添加操作
                    var footer_tbody = $('#assessmentLossCheckPriceDetail .fixed-table-body #assessmentLossCheckPriceTable  tbody');
                    footer_tbody.append("<tr style='text-align: left;'>" +
                        "<td colspan='7'>" +
                        "<button id='addassessmentLossCheckPriceTable'type='button' class='btn btn-success dropdown-toggle'>" +
                        "<span class='glyphicon glyphicon  glyphicon-plus' aria-hidden='true'></span>增加" +
                        "</button>" +
                        "</td>" +

                        "</tr>");
                    $("#addassessmentLossCheckPriceTable").click(function(){
                        $.ajax({
                            url: "assessmentLossCheckPriceDetail/add",
                            data: {renwuhao:renwuhao},
                            dataType: "JSON",
                            type: "POST",
                            async: false,
                            success: function (data) {
                                //console.log(data.data.ids);
                                if (data.status==1) {
                                    $table.bootstrapTable('insertRow', {
                                        index: 0,
                                        row: {
                                            xzmc: '车辆损失险',
                                            xlxm: '',
                                            gsbj: '0.00',
                                            gsfhs:'0.00',
                                            zhuangtai:'',
                                            ids:data.data.ids
                                        }
                                    });
                                } else {
                                    alert("添加失败");
                                }

                            }
                        })

                    });
                    var sum_1 = 0;
                    var sum_2 = 0;
                    for (var k in data.rows) {
                        sum_1 = parseFloat(sum_1) + parseFloat(data.rows[k].gsbj);
                        sum_2 = parseFloat(sum_2) + parseFloat(data.rows[k].gsfhs);
                    }
                    //  $("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:lt(3)").remove();
                    //  $("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:gt(1)").remove();
                    //$("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:eq(0)").prop("colspan",4);
                    // $("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:eq(1)").prop("colspan",3);
                    //$("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:eq(4)").append("合计");
                    /* var rows = [];
                     rows.push({
                         //staffNo: "合计:",
                         gsbj: parseInt(sum_1),
                         gsfhs: parseInt(sum_2)
                     });
                     $table.bootstrapTable('append', rows);*/
                    // $("#assessmentLossCheckPriceDetail .fixed-table-footer table tbody tr td:gt(0)").append("<td colspan='4'><div class='th-inner'></div><div class='fht-cell'></div>"+sum_1+"</td><td colspan='3'>"+sum_2+"</td>");
                },
                onLoadSuccess: function (data) {  //加载成功时执行
                    /*var sum_1 = 0;
                    var sum_2 = 0;
                    for (var k in data.rows) {
                        sum_1 = parseFloat(sum_1) + parseFloat(data.rows[k].gsbj);
                        sum_2 = parseFloat(sum_2) + parseFloat(data.rows[k].gsfhs);
                    }
                    console.log("sum_1="+sum_1);
                    var rows = [];
                    rows.push({
                        //staffNo: "合计:",
                        gsbj: parseInt(sum_1),
                        gsfhs: parseInt(sum_2)
                    });
                    $table.bootstrapTable('append', rows);*/
                },
                onLoadError: function () {  //加载失败时执行
                    //layer.msg("加载数据失败", {time: 1500, icon: 2});
                },

            });
        };

        //得到查询的参数
        oAssessmentLossCheckPriceTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,   //页面大小
                offset: params.offset,  //页码
                renwuhao:renwuhao,//任务号
            };
            return temp;
        };
        return oAssessmentLossCheckPriceTableInit;


    }
    //险种说明
    var ManHourInit=function(renwuhao){
        var oManHourTableInit=new Object();
        oManHourTableInit.Init=function () {
            var $table=$('#manHourTable');
            $table.bootstrapTable({
                url: 'manHour/list',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                contentType : "application/x-www-form-urlencoded",//添加此方法使后台可以获取数据
                //toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sortable: false,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                queryParams: oManHourTableInit.queryParams,//传递参数（*）
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber:1,                       //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [10, 20, 30, 50],        //可供选择的每页的行数（*）
                // search: true,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                // strictSearch: true,
                showColumns: true,                  //是否显示所有的列
                showRefresh: true,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                //clickToSelect: true,                //是否启用点击选中行
                //height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                //uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
                showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                showFooter:true,//显示页脚
                editable:true,//开启编辑模式
                columns: [{
                    checkbox: true
                }, {
                    field: 'dsxz',
                    title: '定损险种',
                    formatter:function (val,row,index) {
                        var selected = '';
                        var selected1 = '';
                        if(val==1){
                            selected1="selected";
                        }else{
                            selected="selected";
                        }
                        return "<select style=\"height:100%;width:100%;padding: 0; margin: 0;\" onchange=\"selectOnchang(this, " + row.ids + ")\">\n" +
                                    "<option value ='' "+selected+">"+'-请选择-'+"</option>" +
                                    "<option value ='1' "+selected1+">"+'车辆损失险'+"</option>" +
                                "</select>";
                    }

                }, {
                    field: 'fylx',
                    title: '费用类型',
                    formatter:function(val,row,index){
                        var jichu_selct = '';
                        var jinjie_select = '';
                        var gaoji_select = "";
                        if (val == 0) {
                            jichu_selct = 'selected'
                        } else if (val == 1) {
                            jinjie_select = 'selected'
                        } else {
                            gaoji_select = 'selected'
                        }
                   /*bootstrap table 添加下拉框*/
                        return "<select style=\"height:100%;width:100%;\" onchange=\"selectOnchang(this, " + row.id + ")\">\n" +
                            "  <option value ='0' "+jichu_selct+">"+'-请选择-'+"</option>\n" +
                            "  <option value ='1' "+jinjie_select+">"+'公估费'+"</option>\n" +
                            "  <option value='2' "+gaoji_select+">"+'施救费'+"</option>\n" +
                            "  <option value='3' "+gaoji_select+">"+'吊装费'+"</option>\n" +
                            "  <option value='4' "+gaoji_select+">"+'施救费'+"</option>\n" +
                            "  <option value='5' "+gaoji_select+">"+'吊装费'+"</option>\n" +
                        "</select>"
                    }
                    /*editable: {
                        type: 'select',//下拉框
                        title: '状态',
                       // disabled:true,//禁用编辑
                        source: [{value: "公估费", text: "公估费"}, {value: "施救费", text: "施救费"}, {value: "吊装费", text: "吊装费"}, {value: "拖车费", text: "拖车费"}, {value: "清洁费", text: "清洁费"}]
                    },*/


                }, {
                    field: 'fyje',
                    title: '费用金额',
                    formatter:function actionFormatte (val,row,index) {
                        return "<input value='"+val+"'style='height:100%;width:100%;padding:0px;margin: 0px;' class='editFee' onkeyup= \"if(! /^[0-9]{1,}(?:.[0-9]{0,2})?$/.test(this.value)){alert('只能输入数字,小数点后只能保留两位');this.value=this.defaultValue;}\"/>";
                    },
                    events: {
                        'blur .editFee': function(e, value, row, index) {
                           // alert(this.defaultValue);
                            var oldVal=this.defaultValue;
                            var newVal=$(this).val();
                            this.defaultValue=newVal;

                            if (newVal!=''){
                                //var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                               /* if (!newVal.match(reg)){
                                    alert( "金额的输入格式不正确,请确认!");
                                }else{

                                }*/
                                if(newVal!=oldVal){//可修改
                                    console.log("修改ids="+row.ids+",'fyje'");
                                    updateFee(this,newVal,row.ids,'fyje',"manHour/saveOrUpdate","POST")

                                }else{//不用修改
                                    console.log("不用修改");

                                }
                            }else{
                                alert("输入错误");
                            }
                        }

                        },
                   /* editable:{
                        type:'text',
                        title:'费用金额',
                        validate:function(v){
                            if (!v) return '不能为空';
                            var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                            if (!reg.test(v)){
                                return "金额的输入格式不正确,请确认!";
                            }
                        }

                    },*/
                    footerFormatter: function (value) {
                        var count=0;
                        for (var i in value) {
                            var val=value[i].fyje;
                            if(!isNaN(value[i].fyje)){
                                //console.log("数据类型:"+ typeof parseFloat(value[i].gsbj))
                                count += (parseFloat(value[i].fyje));
                            }

                        }
                        return "总计："+count.toFixed(2);
                    }


                }, {
                    field: 'hsje',
                    title: '工时费核损',
                    formatter:function actionFormatte(val,row,index){
                        return "<input value='"+val+"' style='height:100%;width:100%;padding:0px;margin: 0px;' class='editFee' onkeyup= \"if(! /^[0-9]{1,}(?:.[0-9]{0,2})?$/.test(this.value)){alert('只能输入数字,小数点后只能保留两位');this.value=this.defaultValue;}\"/>";
                    },
                    events:feeUpdateEvent,
                    footerFormatter: function (value) {
                        var sum=0;
                        for (var k in value) {
                            var val=value[k].hsje;
                            if(val!="工时费核损"){
                                if(!isNaN(val)){
                                    sum = parseFloat(sum)+parseFloat(val);
                                }
                            }
                        }
                        return "总计:"+sum.toFixed(2);
                    }
                },
                    {
                        field: 'sm',
                        title: '说明',
                        /*editable:{
                            type:'text',
                            title:'说明',
                            validate:function(v){
                                if (!v) return '不能为空';
                            }
                        },*/
                        formatter:function f(val,row,index) {
                            return "<input value='"+val+"'style='height:100%;width:100%;padding:0px;margin: 0px;'/>";
                            
                        }

                    },
                    {
                        field: 'ids',
                        title: '操作',
                        width: 120,
                        align: 'center',
                        valign: 'middle',
                        formatter: function actionFormatter(value, row, index) {
                            ///* onclick='delFixedLossCheckPriceDetail("+row.ids+");'*/
                            return "<button type='button'class='delManHour'>删除</button>";
                        },events: {
                            'click .delManHour': function(e, value, row, index) {

                                //alert("e="+e+",value="+value+",index"+index);
                                BootstrapDialog.show({
                                    title: '确认删除',
                                    message: '是否删除？',
                                    type:BootstrapDialog.TYPE_WARNING,
                                    size:BootstrapDialog.SIZE_SMALL,
                                    buttons: [{
                                        label: '确认',
                                        action: function(dialog) {
                                            //console.log("id==="+JSON.stringify(row));
                                            $.ajax({
                                                url:"manHour/delById",
                                                data:{id:row.ids},
                                                dataType:"JSON",
                                                type:"GET",
                                                async:false,
                                                success:function(data){
                                                    if(data!=null){
                                                        if(data.status==1){
                                                            $table.bootstrapTable('remove',{
                                                                field:'ids',
                                                                values:[row.ids],
                                                            })
                                                            dialog.close();
                                                        }

                                                    }


                                                },
                                                error:function(){

                                                }
                                            })


                                        }
                                    }, {
                                        label: '取消',
                                        action: function(dialog) {
                                            dialog.close();
                                        }
                                    }]
                                });

                            }
                        }
                    },],
                onEditableSave: function (field, row, oldValue, $el) {
                    //$table = $('#table1').bootstrapTable({});
                    //console.log("field="+field+",oldValue="+oldValue+",newval="+row[field]);
                    var newValue=row[field];
                    if(''!=newValue) {
                        if (newValue != oldValue) {
                            var map=new Map();
                            map[field]=newValue;
                            map['ids']=row.ids;
                            $.ajax({
                                url: 'manHour/update',
                                data: map,
                                dataType: 'JSON',
                                type: 'POST',
                                async: false,
                                success: function (data) {
                                    console.log(data.status);
                                    if (data.status == 1) {
                                        //saveData(index, field, tdValue);
                                        //$table.bootstrapTable('updateRow', {index: row.rowId, row: row});
                                    } else {
                                        BootstrapDialog.show({
                                            title: '提示信息',
                                            message: data.msg,
                                            type: BootstrapDialog.TYPE_WARNING,
                                            size: BootstrapDialog.SIZE_SMALL,
                                            buttons: [{
                                                label: '确认',
                                                action: function (dialog) {
                                                    dialog.close();
                                                }
                                            }]
                                        });

                                    }

                                },
                                error: function () {

                                }


                            })
                        }
                    }

                },

                onPostBody: function (data) {

                    /*if(footer_val!=''){
                        //第一列为:'平均分',第二列为平局分内容
                        for(var i=0;i<4;i++) {
                            footer_td.eq(i).hide();
                        }

                    }*/


                    /*for(var k=5;k<7;i++) {
                        footer_td.eq(k).remove();
                    }*/
                    // var footer_td_1 = footer_td.eq(3);
                    // footer_td_1.attr('colspan', 4).show();
                    // var footer_td_1 = footer_td.eq(1);
                    // footer_td_1.attr('colspan', 3).show();


                    //添加操作
                    var footer_tbody = $('#manHour .fixed-table-body #manHourTable  tbody');
                    footer_tbody.append("<tr style='text-align: left;'>" +
                        "<td colspan='7'>" +
                        "<button id='addManHour'type='button' class='btn btn-success dropdown-toggle'>" +
                        "<span class='glyphicon glyphicon  glyphicon-plus' aria-hidden='true'></span>增加" +
                        "</button>" +
                        "</td>" +
                        // "<td colspan='5' class='form-horizontal'><labe style='width: 5%;'class='text-left'>定损说明(<span style='color:red;'>200</span>/200)</label>" +
                        // "<textarea style='width:85%;' class='form-control text-right' rows='4'></textarea>"+
                        // "</td>" +
                        "</tr>");


                    $("#addManHour").click(function(){
                       var tabDatas= $table.bootstrapTable('getOptions');
                       var jsonData=JSON.stringify(tabDatas);
                       var count=tabDatas.totalRows;
                       var mapPaream={};
                        if(count>=1){
                            var preData=tabDatas['data'][count-1];
                            mapPaream={dsxz: '车辆损失险',
                                fylx: preData.fylx,
                                fyje: preData.fyje,
                                hsje:preData.hsje,
                                sm:preData.sm,
                                renwuno:renwuhao,
                            }
                        }else{
                            mapPaream={dsxz: '车辆损失险',
                                fylx: '',
                                fyje: '0.00',
                                hsje:'0.00',
                                sm:'',
                                renwuno:renwuhao,
                            }

                        }
                      /*  $table.bootstrapTable('selectPage', 1); //Jump to the first page


                        var rows1={dsxz: '车辆损失险',
                            fylx: '',
                            fyje: '',
                            hsje:'',
                            sm:'',
                            ids:datas.data.ids
                        }
                        $table.bootstrapTable('prepend', rows1); //the method of prepend must defined all fields，but append needn't

                        $("#manHourTable tr:eq(1) td:eq(0)").trigger("dblclick");
                        $("#manHourTable input")[0].focus();
                        return false;*/



                        //var obj=tabDatas['data'][count-1]['ids'];
                        //alert(JSON.stringify(mapPaream));


                        $.ajax({
                            url: "manHour/add",
                            data: mapPaream,
                            dataType: "JSON",
                            type: "POST",
                            async: false,
                            success: function (datas) {
                                //console.log(data.data.ids);
                                if (datas.status==1) {
                                    $table.bootstrapTable('selectPage', 1); //Jump to the first page


                                        var rows1={dsxz: '车辆损失险',
                                            fylx: '',
                                            fyje: '',
                                            hsje:'',
                                            sm:'',
                                            ids:datas.data.ids
                                        }
                                        $table.bootstrapTable('prepend', rows1); //the method of prepend must defined all fields，but append needn't

                                    $("#manHourTable tr:eq(1) td:eq(0)").trigger("dblclick");
                                    $("#manHourTable input")[0].focus();
                                    // $table.bootstrapTable('insertRow', {
                                    //     index: data,
                                    //     row: {
                                    //         dsxz: '车辆损失险',
                                    //         fylx: '',
                                    //         fyje: '0.00',
                                    //         hsje:'0.00',
                                    //         sm:'',
                                    //         ids:data.data.ids
                                    //     }
                                    // });
                                } else {
                                    alert("添加失败");
                                }

                            }
                        })

                    });



                    },
                    /*onLoadSuccess: function (data) {  //加载成功时执行
                        var footer_tbody = $('#manHour .fixed-table-footer table tbody ');
                        var footer_tr = footer_tbody.find('tr:eq(0)');
                        var footer_td = footer_tr.find('td');
                        var footer_val=footer_td.find('.th-inner').text();

                        footer_td.each(function(index){
                            console.log(index);
                            var s=$(this).children("div:first").text();
                            console.log("输出值："+s);
                            //$(this).hide();
                            if(index==3) {
                               $(this).attr('colspan', 4).show();
                                s1=$(this).children("div:first").text()
                            }else if(index==4){
                                $(this).attr('colspan', 3).show();
                                s2=$(this).children("div:first").text()
                            }else{

                               $(this).hide();
                                //$(this).children("div:first").text(index)
                            }


                        });


                    },*/
                    onLoadError: function () {  //加载失败时执行
                    //layer.msg("加载数据失败", {time: 1500, icon: 2});
                    },

            });
        };

        //得到查询的参数
        oManHourTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,   //页面大小
                offset: params.offset,  //页码
                renwuno:renwuhao,//任务号
            };
            return temp;
        };
        return oManHourTableInit;


    }

    /**
     * 更新
     * @param val this
     * @param value 需要修改的值
     * @param ids 修改的对象的id
     * @param name 修改项
     * @param url 请求路径
     * @param type 请求类型POST/GET
     */
    function  updateFee(val,value,ids,name,url,type){
        var map=new Map();
        map[name]=value;
        map['ids']=ids;
        $.ajax({
            url: url,
            data: map,
            dataType: 'JSON',
            type: type,
            async: false,
            success: function (data) {
                console.log(data.status);
                if (data.status == 1) {
                    val.defaultValue=value;
                    console.log(data.msg);
                    //saveData(index, field, tdValue);
                    //$table.bootstrapTable('updateRow', {index: row.rowId, row: row});
                } else {
                    BootstrapDialog.show({
                        title: '提示信息',
                        message: data.msg,
                        type: BootstrapDialog.TYPE_WARNING,
                        size: BootstrapDialog.SIZE_SMALL,
                        buttons: [{
                            label: '确认',
                            action: function (dialog) {
                                dialog.close();
                            }
                        }]
                    });

                }

            },
            error: function () {
                alert("更新出错");
            }


        })

    }


</script>
<body>
<div id="container">
    <!--整个form表单最外层开始-->
    <div id="myForm" class="myForm">
        <!--form表单开始-->
        <form class="form-inline " role="form" action="selfCar/save" method="post" id="formdemo">
            <table class="table table-bordered table-condensed " id="leftRightAlignment">
               <tbody>
                   <tr>
                       <td>
                           修理厂名称:
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" class="form-control width80" name="repairDepotName" id="repairDepotName"/>
                           </label>
                       </td>
                       <td>
                           修理厂类型:
                       </td>
                       <td>
                           <label class="form-group">
                               <select name="repairDepotType" class="select-form-control form-control" id="repairDepotType" >
                                   <option value="">--请选择--</option>
                                   <option value="0">合作修理厂</option>
                                   <option value="1">修理厂</option><option value="1">合作修理厂</option>
                                   <option value="2">快修店</option>
                                   <option value="3">4S店</option>

                               </select>
                           </label>
                       </td>
                       <td>
                           车牌号:
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="car.licenceNo" id="licenceNo" class="form-control"/>
                           </label>
                       </td>
                   </tr>
               <tr>
                   <td>
                    修理厂情况
                   </td>
                   <td colspan="3">
                       <label class="form-group">
                           <!--<select name="chooseRepairDepotType" id="chooseRepairDepotType" class="select-form-control form-control">-->
                               <!--<option value="">&#45;&#45;请选择&#45;&#45;</option>-->
                               <!--<option value="1">客户自选1</option>-->
                               <!--<option value="2">客户自选2</option>-->
                               <!--<option value="3">客户自选3</option>-->
                           <!--</select>-->
                           <input value="" name="chooseRepairDepotType" id="chooseRepairDepotType" class="form-control"/>

                       </label>
                   </td>
                   <td>组织机构代码</td>
                   <td>
                       <label class="form-group">
                           <input value="" name="orgCode" id="orgCode" class="form-control"/>
                       </label>
                   </td>
               </tr>
               <tr>
                   <td>
                        被保险人
                   </td>
                   <td>
                       <label class="form-group">
                           <input value="" name="recognizee" id="recognizee" class="form-control">
                       </label>
                   </td>
                   <td>
                       行驶证车主
                   </td>
                   <td>
                       <label class="form-group">
                           <input value="" name="car.driverName" id="driverName" class="form-control">
                       </label>
                   </td>
                   <td>
                        号牌类型
                   </td>
                   <td>
                       <label class="form-group">
                           <select class="select-form-control form-control" name="car.modelType" id="licenseNoType">
                               <option value="2">02-中型汽车品牌</option>
                               <option value="1">01-小型汽车号牌</option>
                               <option value="3">03-大型汽车品牌</option>
                            </select>
                       </label>
                   </td>
               </tr>
               <tr>
                   <td>
                       车架号
                   </td>
                   <td>
                       <label class="form-group">
                           <input value="" name="car.vinNo" id="vinNo" class="form-control">
                       </label>
                   </td>
                   <td>
                       发动机号
                   </td>
                   <td>
                       <label class="form-group">
                           <input value="" name="car.engineNo" id="engineNo" class="form-control" stye="">
                       </label>
                   </td>
                   <td>
                       驾驶员姓名
                   </td>
                   <td>
                       <label class="form-group">
                           <input value="" class="form-control" name="driver" id="driver"/>
                       </label>
                   </td>
               </tr>
                   <tr>
                       <td>
                           证件号码
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="car.idCard" id="idCard" class="form-control">
                           </label>
                       </td>
                       <td>
                           准驾车型
                       </td>
                       <td>
                           <label class="form-group">
                               <select name="ableCarModel" id="car.ableCarModel" class="select-form-control form-control">
                                   <option value="">--请选择--</option>
                                   <option value="0">C1(小型汽车)</option>
                                   <option value="1">C1(小型汽车)</option>
                                </select>
                           </label>
                       </td>
                       <td>
                           驾驶员性别
                       </td>
                       <td>
                           <label class="">
                               <input type="radio" name="car.driverSex" id="girlDriverSex" class="" value="0" checked/> 女
                               <input type="radio" name="car.driverSex" id="boyDriverSex" class="" value="1"/> 男
                             </label>
                       </td>
                   </tr>
                   <tr>
                       <td>
                           生产厂家
                       </td>
                       <td>
                           <label class="form-group">
                               <!--<select class="select-form-control form-control" name="car.manufactuer" id="manufactuer">-->
                                   <!--<option value="">&#45;&#45;请选择&#45;&#45;</option>-->
                                   <!--<option value="德国奥迪汽车股份有限公司1">德国奥迪汽车股份有限公司1</option>-->
                                   <!--<option value="德国奥迪汽车股份有限公司2">德国奥迪汽车股份有限公司2</option>-->
                               <!--</select>-->
                               <input value="" class="form-control" name="car.manufactuer" id="manufactuer" />
                           </label>

                       </td>
                       <td>
                           车辆品牌
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" class="form-control" name="car.brand" id="brand" />
                           </label>
                       </td>
                       <td>
                           车型系列
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="car.series" id="series" class="form-control">
                           </label>
                       </td>
                   </tr>
                   <tr>
                       <td>
                           车辆型号
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="car.model" id="model" class="form-control">
                           </label>
                       </td>
                       <td>
                           生产年份
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="car.produceDate" id="produceDate" class="form-control">
                           </label>
                       </td>
                       <td>
                           车损定损合计
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="fixedLossTotal" id="fixedLossTotal" class="form-control">
                           </label>
                       </td>
                   </tr>
                   <tr>
                       <td>
                           定损险种
                       </td>
                       <td>
                           <label class="form-group">
                               <select class="form-control" name="fixedLossInsureType" >
                                   <option value="1">第三方责任险</option>
                                   <option value="2">第二方责任险</option>
                               </select>
                           </label>
                       </td>
                       <td>事故责任</td>
                       <td >
                           <label class="form-group">
                           <select class="form-control" name="accidentDuty" >
                               <option value="0">全责</option>
                               <option value="1">主责</option>
                               <option value="2">次责</option>
                               <option value="3">无责</option>
                               <option value="4">无法确认责任</option>
                           </select>
                           <input value="100" class="width80" id="accidentDutypPercent"/></label>
                       </td>
                       <td>
                           车损核价合计
                       </td>
                       <td>
                           <label class="form-group">
                               <input value="" name="checkPriceTotal" id="checkPriceTotal" class="form-control">
                           </label>
                       </td>
                   </tr>
               </tbody>
           </table>
            <!--计算折旧价格开始-->
            <div id="calculateSalePrice" >
                <div class="row margin20top">
                    <div class="col-md-12 " style="line-height: 30px;"> 计算折旧价格</div>
                </div>
                <div class="row margin10top">
                    <div class="col-md-3 col-xs-3 col-sm-3">
                        <label>新车购置价:</label>
                        <label class="form-group">
                            <input value="" class="form-control" name="car.newCarPrice" id="newCarPrice" style="width: 150px;"/>
                        </label>
                    </div>
                    <div class="col-md-5 col-xs-5 col-sm-5">
                        <label>车辆种类:</label>
                        <label class="form-group">
                            <select  name="car.carKind" class="form-control">
                                <option value="1">9座(含9座)以下非营运运载客汽车</option>
                            </select>
                        </label>
                    </div>
                    <div class="col-md-4 col-xs-4 col-sm-4">

                        <label class="form-group">折旧率
                            <input value="0.0006" class="form-control" name="changeOldRate" id="changeOldRate" />
                        </label>
                    </div>
                </div>
                <div class="row margin5top">
                    <div class="col-md-3 col-xs-3 col-sm-3 ">
                        <label>出险时间:</label>
                        <label class="form-group">
                            <input value="" class="width100 form-control" name="outDangerDate" id="outDangerDate" style="width: 160px;"/>
                        </label>
                    </div>
                    <div class="col-md-5 col-xs-5 col-sm-5">
                        <label class="form-group">初登日期:
                            <input value="" name="car.registerDate" id="carRegisterDate" class="form-control"/>
                        </label>
                    </div>
                    <div class="col-md-4 col-xs-4 col-sm-4">

                        <label class=""> 计算公式</label>
                        <label class="form-group">
                            <input value="" class="width10 form-control" name="calculationFormula" id="calculationFormula"/>
                        </label>
                            <input type="button" class="btn-sm btn-info" value="计算"/>
                    </div>
                </div>

                <!--计算折旧价格结束-->
                <!--定损核价明细开始-->
                <div id="fixedLossPricingDetail" style="margin-top: 10px;">
                    <div class="row">
                        <div class="col-md-12">
                            <!--定损核价明细-->
                            <div class="table-box" style="margin:0px;">
                                <div class="col-md-12" style="line-height: 30px;background-color: #98ceea;">定损、核价明细</div>
                                <div id="toolbar">
                                </div>
                                <table id="partTable"></table>
                            </div>
                        </div>
                    </div>
                </div>
                <!--估损核价明细开始-->
                <div id="assessmentLossCheckPriceDetail">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="table-box" style="margin: 0px;">
                                <div class="col-md-12" style="line-height: 30px;background-color: #98ceea;">估损核价明细</div>
                                <div id="toolbar2">
                                        <!--<button id="button" class="btn btn-default">insertrow</button>
                                        <button id="getTableData" class="btn btn-default">getTableData</button>-->
                                </div>
                                <table id="assessmentLossCheckPriceTable"></table>
                            </div>
                        </div>
                    </div>
                </div>
                <!--估损核价明细结束-->
                <!--费用信息开始-->
                <div id="manHour">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="table-box" style="margin: 0px;">
                                <div class="col-md-12" style="line-height: 30px;background-color: #98ceea;">费用信息</div>
                                <div id="toolbar3">
                                    <!--<button id="button" class="btn btn-default">insertrow</button>
                                    <button id="getTableData" class="btn btn-default">getTableData</button>-->
                                </div>
                                <!--//<fieldset disabled="disabled">-->
                                <table id="manHourTable" class="table-condensed"></table>
                                <!--</fieldset>-->
                            </div>
                        </div>
                    </div>
                </div>
                <!--费用信息结束-->
                <!--定损说明开始-->
                <div id="fixedLossInstruction">
                    <div class="row">
                        <div class="col-md-12 text-center">
                            <div>
                            <span style="width:8%;top:-10px;" class="text-center" >定损说明(<span style="color: red;">200</span>/200)</span>
                            <textarea style="width:85%;" rows="4" ></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <!--定损说明结束-->
                <!--历史信息开始-->
                <div class="historyInfo margin10top" id="historyInfo" >
                    <div class="modelTitle"><label>历史信息</label></div>
                    <table class="table table-bordered table-condensed">
                        <thead>
                        <tr class="tableTheadcolor">
                            <th>序号</th>
                            <th>操作人</th>
                            <th>操作机构</th>
                            <th>操作时间</th>
                            <th>操作类型</th>
                            <th>操作结论</th>
                            <th>次数</th>
                            <th>配件金额</th>
                            <th>定损金额</th>
                            <th>操作说明</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>1</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>

                        </tr>
                        <tr>
                            <td colspan="10">
                                <button type="button" class="btn-sm ">图片上传</button>
                                <button type="button" class="btn-sm ">图片预览</button>
                                <button type="button" class="btn-sm ">影响资料</button>
                                <button type="button" class="btn-sm ">关闭</button>
                                <button type="button" class="btn-sm ">提交</button>
                                <button type="button" class="btn-sm btn-info" onclick="save();" id="saveBtn">保存</button>
                                <button type="button" class="btn btn-sm">历史信息</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
               <!-- 历史信息结束-->
            </div>

        </form>
        <!--form表单结束-->

    </div>
    <!--整个form表单最外层结束-->
</div>
<script>
    jQuery(function($){
        //解决模态框背景色越来越深的问题
        $(document).on('show.bs.modal', '.modal', function(event) {
            $(this).appendTo($('body'));
        }).on('shown.bs.modal', '.modal.in', function(event) {
            setModalsAndBackdropsOrder();
        }).on('hidden.bs.modal', '.modal', function(event) {
            setModalsAndBackdropsOrder();
        });

        function setModalsAndBackdropsOrder() {
            var modalZIndex = 1040;
            $('.modal.in').each(function(index) {
                var $modal = $(this);
                modalZIndex++;
                $modal.css('zIndex', modalZIndex);
                $modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
            });
            $('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
        }

        //覆盖Modal.prototype的hideModal方法
        $.fn.modal.Constructor.prototype.hideModal = function () {
            var that = this;
            this.$element.hide();
            this.backdrop(function () {
                //判断当前页面所有的模态框都已经隐藏了之后body移除.modal-open，即body出现滚动条。
                $('.modal.fade.in').length === 0 && that.$body.removeClass('modal-open');
                that.resetAdjustments();
                that.resetScrollbar();
                that.$element.trigger('hidden.bs.modal');
            })
        }
    });

    //身份证检验
    var vcity={ 11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",
        21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
        33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",
        42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",
        51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",
        63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"
    };

    function checkCard(card){
        //是否为空
        if(!card||!isCardNo(card)||!checkProvince(card)||!checkBirthday(card)||!checkParity(card)){
            ZlyJs.divTip("请输入正确的身份证号码");
            jQuery(".sf_list").focus();
            return false;
        }
        return true;
    };


    //检查号码是否符合规范，包括长度，类型
    function isCardNo(card){
        //身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X
        var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
        if(reg.test(card) === false){
            return false;
        }
        return true;
    };

    //取身份证前两位,校验省份
    function checkProvince(card){
        var province = card.substr(0,2);
        if(vcity[province] == undefined) {
            return false;
        }
        return true;
    };

    //检查生日是否正确
    function checkBirthday(card){
        var len = card.length;
        //身份证15位时，次序为省（3位）市（3位）年（2位）月（2位）日（2位）校验位（3位），皆为数字
        if(len == '15'){
            var re_fifteen = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/;
            var arr_data = card.match(re_fifteen);
            var year = arr_data[2];
            var month = arr_data[3];
            var day = arr_data[4];
            var birthday = new Date('19'+year+'/'+month+'/'+day);
            return verifyBirthday('19'+year,month,day,birthday);
        }
        //身份证18位时，次序为省（3位）市（3位）年（4位）月（2位）日（2位）校验位（4位），校验位末尾可能为X
        if(len == '18'){
            var re_eighteen = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
            var arr_data = card.match(re_eighteen);
            var year = arr_data[2];
            var month = arr_data[3];
            var day = arr_data[4];
            var birthday = new Date(year+'/'+month+'/'+day);
            return verifyBirthday(year,month,day,birthday);
        }
        return false;
    };

    //校验日期
    function verifyBirthday(year,month,day,birthday){
        var now = new Date();
        var now_year = now.getFullYear();
        //年月日是否合理
        if(birthday.getFullYear() == year && (birthday.getMonth() + 1) == month && birthday.getDate() == day){
            //判断年份的范围（3岁到100岁之间)
            var time = now_year - year;
            if(time >= 3 && time <= 100)
            {
                return true;
            }
            return false;
        }
        return false;
    };
    //校验位的检测
    function checkParity(card){
        //15位转18位
        card = changeFivteenToEighteen(card);
        var len = card.length;
        if(len == '18'){
            var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
            var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
            var cardTemp = 0, i, valnum;
            for(i = 0; i < 17; i ++){
                cardTemp += card.substr(i, 1) * arrInt[i];
            }
            valnum = arrCh[cardTemp % 11];
            if(valnum == card.substr(17, 1)){
                return true;
            }
            return false;
        }
        return false;
    };
    //15位转18位身份证号
    function changeFivteenToEighteen(card){
        if(card.length == '15'){
            var arrInt = new array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
            var arrCh = new array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
            var cardTemp = 0, i;
            card = card.substr(0, 6) + '19' + card.substr(6, card.length - 6);
            for(i = 0; i < 17; i ++){
                cardTemp += card.substr(i, 1) * arrInt[i];
            }
            card += arrCh[cardTemp % 11];
            return card;
        }
        return card;
    };
   /* if (!checkCard(code)) {
        alert("请输入正确的身份证号码");
        return false;
    }*/

   // $(function(){
   //     var oTable = new TableInit();
   //     oTable.Init();
   // })
    //$(function() {
       /* var oTable = new TableInit();
        oTable.Init();*/
     function tableInit(renwubianhao) {

            var $table = $('#partTable');
            var $getTableData = $('#getTableData');
            $table.bootstrapTable({
                // url: './testData/data.json',
                url: 'fixedLossCheckPriceDetail/findPageByTaskNum',//请求后台的URL（*）
                method: "GET",//请求方式（*）
                toolbar: '#toolbar',//工具按钮用哪个容器
                striped: true, //是否显示行间隔色
                cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true, //是否显示分页（*）
                // sortable: false, //是否启用排序
                // sortOrder: "asc", //排序方式
                sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1, //初始化加载第一页，默认第一页
                pageSize: 20, //每页的记录行数（*）
                pageList: [20, 50], //可供选择的每页的行数（*）
                // search: false, //是否显示表格搜索，此搜索是客户端搜索,也可以是服务端检索
                // strictSearch: true,
                //clickEdit: true,
               // clickToSelect: true,                //是否启用点击选中行
                type: 'select',
                /*editable: true,//开启编辑模式*/
                /*editable: true,//开启编辑模式*/
                showToggle: true,//是否显示详细视图和列表视图的切换按钮
                showColumns: true,//是否显示所有的列
                showPaginationSwitch: true,     //显示切换分页按钮
                minimumCountColumns: 2, //最少允许的列数
                // clickToSelect: true, //是否启用点击选中行
                //  height: 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                //  uniqueId: "id", //每一行的唯一标识，一般为主键列
                showRefresh: true,      //显示刷新按钮
                // cardView: false, //是否显示详细视图
                // detailView: false, //是否显示父子表
                //clickToSelect: true,  //点击row选中radio或CheckBox
                ///showFooter:true,//显示页脚
                //showExport: true, //是否显示导出
                //exportDataType: "selected", //basic', 'all', 'selected'.
                queryParams: function (params) { // 请求服务器数据时发送的参数，可以在这里添加额外的查询参数，返回false则终止请求
                    return {
                        limit: params.limit, // 每页要显示的数据条数
                        offset: params.offset, // 每页显示数据的开始行号
                        page: params.offset / params.limit + 1,
                        renwubianhao:renwubianhao,
                        //sort: params.sort// 要排序的字段
                        // ,sortOrder: params.order, // 排序规则
                        // dataId: $("#dataId").val() // 额外添加的参数
                    }
                },
                // rowStyle: function (row, index) {
                //     //这里有5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
                //     var strclass = "";
                //     if (row.ORDER_STATUS == "待排产") {
                //         strclass = 'success';//还有一个active
                //     }
                //     else if (row.ORDER_STATUS == "已删除") {
                //         strclass = 'danger';
                //     }
                //     else {
                //         return {};
                //     }
                //     return { classes: strclass }
                // },
                columns: [

                    [
                        {
                            "title": "定损核价明细",
                            "halign": "center",
                            "align": "center",
                            "colspan": 11,
                            //"cellStyle": formatTableUnit
                            "cellStyle":function (value,row,index){
                              return{  css:{"background-color":"red"}}
                            }

                            /*    "cellStyle":function cellStyle (value, row, index ) {

                            return {
                            css: {
                                "color":"red",
                                "background-color": "red"
                            }
                        }
                        }*/


                        },

                    ],

                    [
                        /*{
                        checkbox: true
                    },*/
                        {
                            field: 'xzmc',
                            title: '险种名称'
                        },

                        /*{
                            field:'renwubianhao',
                            title:'任务编号',
                            hidden: false,
                        },*/
                        {
                            field: 'pjmc',
                            title: '配件名称',
                            formatter: function (value, row, index) {
                                //return value;
                                return ["<input type='text' value='"+value+"'/>"].join("");

                            },
                            // editable:{
                            //     type:'text',
                            //     title:'配件名称',
                            //     validate:function(v){
                            //         if (!v) return '不能为空';
                            //     }
                            //
                            // }
                        },
                        {
                            field: 'bdjg',
                            title: '本地价格',
                            /* footerFormatter:function (data) {
                            return "平均分";
                        }*/
                        },
                        {
                            field: 'xtjg',
                            title: '系统价格'
                        },
                        {
                            field: 'sl',
                            title: '数量'
                        },
                        {
                            field: 'dsj',
                            title: '定损价格'
                        },
                        {
                            field: 'hj',
                            title: '核价价格'
                        },
                        {
                            field: 'jgan',
                            title: '价格方案',

                            editable: {
                                type: 'select',//下拉框
                                title: '价格方案',
                                source: [{value: "4S店", text: "4S店"}, {value: "一级汽修", text: "一级汽修"}, {
                                    value: "二级汽修",
                                    text: "二级汽修"
                                },{value: "三级级汽修",
                                    text: "三级汽修"}]


                            }
                        },
                        {
                            field: 'sfhs',
                            title: '是否回收',

                            editable: {
                                type: 'select',//下拉框
                                title: '是否回收',
                                source: [{value: "1", text: "是"}, {value: "0", text: "否"}]

                            },
                            // formatter: function (value, row, index) {
                            //     if (value == 0) {
                            //         return '否';
                            //     } else if (value == 1) {
                            //         return '是';
                            //     } else {
                            //         return value;
                            //     }
                            //
                            // },
                        },
                        {
                            field: 'zhuangtai',
                            title: '状态',
                            /*formatter: function (value, row, index) {
                                if(value==0){
                                    return '未完成';
                                }else if(value==1){
                                    return '完成';
                                }else {
                                    return value;
                                }
                            },*/
                            editable: {
                                type: 'select',//下拉框
                                title: '状态',
                                source: [{value: "1", text: "已完成"}, {value: "0", text: "未完成"}]

                            },
                        },
                        {
                            field: 'ids',
                            title: '操作',
                            width: 120,
                            align: 'center',
                            valign: 'middle',
                            formatter: function actionFormatter(value, row, index) {
                                ///* onclick='delFixedLossCheckPriceDetail("+row.ids+");'*/
                                return "<button type='button'class='delFixedLossCheckPriceDetail'>删除</button>";
                            },events: {
                                'click .delFixedLossCheckPriceDetail': function(e, value, row, index) {

                                   //alert("e="+e+",value="+value+",index"+index);
                                    BootstrapDialog.show({
                                        title: '确认删除',
                                        message: '是否删除？',
                                        type:BootstrapDialog.TYPE_WARNING,
                                        size:BootstrapDialog.SIZE_SMALL,
                                        buttons: [{
                                            label: '确认',
                                            action: function(dialog) {
                                                console.log("id==="+JSON.stringify(row));

                                                $.ajax({
                                                    url:"fixedLossCheckPriceDetail/deleteById",
                                                    data:{id:row.ids},
                                                    dataType:"JSON",
                                                    type:"GET",
                                                    async:false,
                                                    success:function(data){
                                                        if(data!=null){
                                                            if(data.status==1){
                                                                $('#table').bootstrapTable('remove',{
                                                                    field:'ids',
                                                                    values:[row.ids],
                                                                })
                                                                dialog.close();
                                                            }

                                                        }


                                                    },
                                                    error:function(){

                                                    }
                                                })


                                            }
                                        }, {
                                            label: '取消',
                                            action: function(dialog) {
                                                dialog.close();
                                            }
                                        }]
                                    });

                                }
                            }
                        },
                    ], /*[
                    {
                        "title": "残值<input value='ss'>",
                        "halign":"right",
                        "align":"right",
                        "colspan": 6
                    },
                    {
                        "title": "残值价格",
                        "halign":"left",
                        "align":"left",
                        "colspan": 5
                    }
                ]*/
                ],
                // onEditableHidden: function(field, row, $el, reason) { // 当编辑状态被隐藏时触发
                //     if(reason === 'save') {
                //         var $td = $el.closest('tr').children();
                //         $td.eq(-1).html((row.price*row.number).toFixed(2));
                //         $el.closest('tr').next().find('.editable').editable('show'); //编辑状态向下一行移动
                //     } else if(reason === 'nochange') {
                //         $el.closest('tr').next().find('.editable').editable('show');
                //     }
                // },
                onEditableSave: function (field, row, oldValue, $el) {
                    //$table = $('#table1').bootstrapTable({});
                    //console.log("field="+field+",oldValue="+oldValue+",newval="+row[field]);
                    var newValue=row[field];
                    if(''!=newValue) {
                        if (newValue != oldValue) {
                            var map=new Map();
                            map[field]=newValue;
                            map['ids']=row.ids;
                            $.ajax({
                                url: 'fixedLossCheckPriceDetail/update',
                                data: map,
                                dataType: 'JSON',
                                type: 'POST',
                                async: false,
                                success: function (data) {
                                    console.log(data.status);
                                    if (data.status == 1) {
                                        //saveData(index, field, tdValue);
                                        //$table.bootstrapTable('updateRow', {index: row.rowId, row: row});
                                    } else {
                                        BootstrapDialog.show({
                                            title: '提示信息',
                                            message: data.msg,
                                            type: BootstrapDialog.TYPE_WARNING,
                                            size: BootstrapDialog.SIZE_SMALL,
                                            buttons: [{
                                                label: '确认',
                                                action: function (dialog) {
                                                    dialog.close();
                                                }
                                            }]
                                        });

                                    }

                                },
                                error: function () {

                                }


                            })
                        }
                    }

                },
                /**
                 * @param {点击列的 field 名称} field
                 * @param {点击列的 value 值} value
                 * @param {点击列的整行数据} row
                 * @param {td 元素} $element
                 */
                onDblClickCell: function (field, value, row, $element) {
                    $element.attr('contenteditable', true);
                    var index = $element.parent().data('index');
                    console.log("触发双击事件");
                    //if (field == 'price') {//当点击最后一个方可保存
                        $element.blur(function () {
                            var tdValue = $element.html();
                            console.log("原值：" + value + ",修改值：" + tdValue+"field="+field);


                            if (""!=tdValue) {//新值不为空
                                if(tdValue!=value){//新值与旧值不同
                                    //console.log("触发一次，ids="+row.ids);
                                    var map={};
                                    map[field]=tdValue;
                                    map['ids']=row.ids;
                                    $.ajax({
                                        url:'fixedLossCheckPriceDetail/update',
                                        data:map,
                                        dataType:'JSON',
                                        type:'POST',
                                        async:false,
                                        success:function(data){
                                            console.log(data.status);
                                            if(data.status==1){
                                                saveData(index, field, tdValue);
                                            }else{
                                                BootstrapDialog.show({
                                                    title: '提示信息',
                                                    message: data.msg,
                                                    type: BootstrapDialog.TYPE_WARNING,
                                                    size: BootstrapDialog.SIZE_SMALL,
                                                    buttons: [{
                                                        label: '确认',
                                                        action: function (dialog) {
                                                            dialog.close();
                                                        }
                                                    }]
                                                });

                                            }

                                        },
                                        error:function(){

                                        }


                                    })


                                }

                            }


                        })
                   /* }*/

                }
                , onPostBody: function (data) {
                    //合并页脚
                    //merge_footer();
                    addBodyFooter();//在表格最后添加行
                    var $add = $("#addFixedLossCheckPriceDetail");
                    var $del=$("#delFixedLossCheckPriceDetail");
                    $add.click(function () {
                        $.ajax({
                            url: "fixedLossCheckPriceDetail/add",
                            data: {renwubianhao:renwubianhao},
                            dataType: "JSON",
                            type: "POST",
                            async: false,
                            success: function (data) {
                                //console.log(data.data.ids);
                                if (data.status==1) {
                                    $table.bootstrapTable('insertRow', {
                                        index: 0,
                                        row: {
                                            xzmc: '车辆损失险',
                                            pjmc: '',
                                            bdjg: '0.00',
                                            xtjg:'0.00',
                                            sl:'0',
                                            dsj:'0.00',
                                            hj:'0.00',
                                            jgan:'',
                                            sfhs:'否',
                                            zhuangtai:'',
                                            ids:data.data.ids
                                        }
                                    });
                                } else {
                                    alert("添加失败");
                                }

                            }
                        })

                    });
                    if(data!=''){
                        var fixedLossSum=0;
                        var checkLossSum=0;
                        $.each(data,function(index,item){
                            console.log(item)
                            if(!isNaN(item.hj)&&item.hj!=""){
                                checkLossSum+=parseFloat(item.hj);
                            }
                            if(!isNaN(item.dsj)&&item.dsj!=''){
                                fixedLossSum+=parseFloat(item.dsj);
                            }
                        });
                        $("#fixedLossSum").val(fixedLossSum.toFixed(2));
                        $("#checkLossSum").val(checkLossSum.toFixed(2));


                    }
                    $("#fixedLossSalvage").blur(function(){
                        var val=$(this).val();
                        if(parseFloat(val).toString()!="NaN"){
                          var fixedLossSum=  $("#fixedLossSum").val();
                            if(parseFloat(val)<parseFloat(fixedLossSum)){
                                $("#fixedLossSum").val((parseFloat(fixedLossSum)-parseFloat(val)).toFixed(2));

                            }
                        }

                    })
                    $("#checkedLossSalvage").blur(function(){
                        var val=$(this).val();
                        if(parseFloat(val).toString()!="NaN"){
                            var fixedLossSum=  $("#checkLossSum").val();
                            if(parseFloat(val)<parseFloat(fixedLossSum)){
                                $("#checkLossSum").val((parseFloat(fixedLossSum)-parseFloat(val)).toFixed(2));

                            }
                        }

                    })

                   //console.log("数据"+data)

                }
            });





            //设置标题
            function formatTableUnit(value, row, index) {
                return {
                    css: {
                        /*"color": front_color,*/
                        "background-color": red
                    }
                }

            }

            /* $getTableData.click(function() {
            alert(JSON.stringify($table.bootstrapTable('getData')));
        });*/


            function saveData(index, field, value) {
                //console.log("index:" + index + ",filed=" + field + ",value=" + value)
                $table.bootstrapTable('updateCell', {
                    index: index,       //行索引
                    field: field,       //列名
                    value: value        //cell值
                })
            }

            //合并页脚
            function merge_footer() {
                var footer_tbody = $('.fixed-table-footer table tbody');
                var footer_tr = footer_tbody.find('>tr').eq(0);
                var footer_td = footer_tr.find('>td');
                var footer_td_1 = footer_td.eq(0);
                //第一列为:'平均分',第二列为平局分内容
                for (var i = 2; i < footer_td.length; i++) {
                    footer_td.eq(i).remove();
                }


                /*  footer_tbody.append("<tr><td colspan='6' style=''></td><td colspan='5'></td></tr>")
            footer_tbody.append("<tr><td colspan='6' style=''></td><td colspan='5'></td></tr>")
            footer_tbody.append("<tr><td colspan='6' style=''></td><td colspan='5'></td></tr>")
            footer_tbody.append("<tr><td colspan='6' style=''></td><td colspan='5'></td></tr>")
*/

                footer_td_1.attr('colspan', 8).show();
            }

            function addBodyFooter() {
                var footer_tbody = $('.fixed-table-body #partTable tbody');
                footer_tbody.append("<tr style='text-align: left;'>" +
                        "<td colspan='11'>" +
                        "<button id='addFixedLossCheckPriceDetail'type='button' class='btn btn-success dropdown-toggle'>" +
                        "<span class='glyphicon glyphicon  glyphicon-plus' aria-hidden='true'></span>增加" +
                        "</button>" +
                        "</td>" +
                    "</tr>" +
                    "<tr style='text-align:right;'>" +
                        "<td colspan='6'>残值<input value=''style='' id='fixedLossSalvage'></td>" +
                        "<td colspan='5' style='text-align:left;'>残值核价<input value=''style='' id='checkedLossSalvage'></td>" +
                    "</tr>" +
                    "<tr style='text-align:right;'>" +
                        "<td colspan='6' >小计：<input value=''style='text'id='fixedLossSum'></td>" +
                        "<td colspan='5' style='text-align:left;'>小计<input id='checkLossSum' value=''style=''>" +
                    "</td>" +
                    "</tr>" +
                    "<tr style='text-align:right;'>" +
                        "<td colspan='6'>指定管理费<input value=''style=''></td>" +
                        "<td colspan='5' style='text-align:left;'>核价管理费<input value=''style=''></td>" +
                    "</tr>");
            }

    }
    //});


</script>
</body>
</html>
